﻿Imports AutoCAD

''' <summary>
''' 绘制平面板件
''' </summary>
Public Class CadDrawFlatServiceImpl
    Private ms As IAcadBlock

    ''' <summary>
    ''' 绘图
    ''' </summary>
    ''' <param name="pl"> 多段线 </param>
    ''' <param name="thickness"> 厚度 </param>
    ''' <returns></returns>
    Public Function draw(ByRef pl As AcadLWPolyline, ByVal thickness As Double) As Acad3DSolid
        Dim arr() As AcadEntity = New AcadEntity() {pl}
        Dim region = ms.AddRegion(arr)
        Dim result As Acad3DSolid = ms.AddExtrudedSolid(region(0), thickness, 0)
        region(0).delete
        Return result
    End Function


    Public Function draw(ByRef plHandle As String, ByVal thickness As Double) As Acad3DSolid
        Dim doc As AcadDocument = ms.Document
        Return draw(doc.HandleToObject(plHandle), thickness)
    End Function


#Region "TEST"

    '测试, 将已存在的多段线创建板件
    Public Sub test()
        Dim plHandle As String = "462"
        Dim cadApplicationService As ICadApplicationService = New CadApplicationServiceImpl
        Dim doc As AcadDocument = cadApplicationService.GetActiveDocument
        Me.ms = doc.ModelSpace
        Dim pl As AcadLWPolyline = doc.HandleToObject(plHandle)
        Dim solid As Acad3DSolid = draw(pl, 15)
    End Sub
#End Region
End Class
